package com.example.onlinemusicserver.service;

import com.example.onlinemusicserver.mapper.CollectMapper;
import com.example.onlinemusicserver.model.Collect;
import com.example.onlinemusicserver.model.Music;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectService {
    @Autowired
    private CollectMapper collectMapper;

    public Collect findCollectMusic(int userId, int musicId) {
        return collectMapper.findCollectMusic(userId,musicId);
    }

    public int insertLoveMusic(int userId, int musicId) {
        return collectMapper.insertLoveMusic(userId, musicId);
    }

    public List<Music> findLoveMusicByUserId(int userId, int pageRange, int pageSize){
        return collectMapper.findLoveMusicByUserId(userId,pageRange,pageSize);
    }

    public List<Music> findLoveMusicByNameAndUserId(String name, int userId, int pageRange, int pageSize){
        return collectMapper.findLoveMusicByNameAndUserId(name,userId,pageRange,pageSize);
    }

    public int deleteLoveMusic(int userId,int musicId){
        return collectMapper.deleteLoveMusic(userId,musicId);
    }

    public int deleteLoveMusicById(int musicId){
        return collectMapper.deleteLoveMusicById(musicId);
    }

    public int totalMusic(String musicName, int userId) {
        return collectMapper.totalMusic(musicName,userId);
    }
}
